Repository navigation
Raise ResourceNotFoundError when moving data rows to a missing task queue - #2103
Merged
Merged
Conversation
…ueue Project.move_data_rows_to_task_queue raised "TypeError: 'NoneType' object is not subscriptable" when the task queue id (or the project) did not exist. The server answers such a call with a RESOURCE_NOT_FOUND error, the client returned None for it, and the method read the task id out of that None. The method now asks the client to raise for a missing resource and re-raises a ResourceNotFoundError that names the task queue id and the project id and keeps the server's message. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
mnoszczak
marked this pull request as ready for review
November 30, 2026 15:16
mnoszczak
requested review from
KeshavSahoo,
cyrusj89,
gmadaan-hue,
jakefleming,
john-labelbox,
labelbox-engineering and
rma-eng-bot
November 30, 2026 15:16
pawelkozik-labelbox
approved these changes
Nov 30, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Project.move_data_rows_to_task_queuecrashed with a PythonTypeErrorwhen the task queue id did not exist. It now raisesResourceNotFoundError(aLabelboxError) with a message that says what was missing.Before
Code that catches
LabelboxErrordid not catch this.After
The same error is raised when the project itself no longer exists. With
task_queue_id=None(the "Done" queue) the message names only the project.Why it happened
The server answers this call with a
RESOURCE_NOT_FOUNDerror when the task queue or the project is missing. By defaultClient.executereturnsNonefor that error and leaves it to the caller to raise.move_data_rows_to_task_queuedid not check forNoneand read["project"][...]["taskId"]straight from the result.The fix
The method now calls
executewithraise_return_resource_not_found=True, the same asProject.clear_queue_reservationsdoes. It catches theResourceNotFoundError, adds the task queue id and project id to the message, keeps the server's message, and raises it again. Nothing changes for calls that succeed.Other
ProjectmethodsI checked the other methods in
project.pythat read the result ofexecutewithout the flag. I found no other one where a wrong id passed by the caller ends in thisTypeError:add_model_configanddelete_project_model_configalready check for an empty result and raiseResourceNotFoundError.create_batches_from_datasetwith an unknown dataset id gets a "malformed request" error from the server, which already raises aLabelboxError.create_batches,create_batch,set_labeling_parameter_overrides,update_data_row_labeling_priorityandbulk_assign_data_rowstake data row or user ids. As far as I could trace, the server does not answer a wrong one with "not found" on the first call, so they do not reach this path.The rest only send the id of the project itself (
task_queues,get_label_count,get_resource_tags,update_project_resource_tags,export_issues,review_metrics,enable_model_assisted_labeling,project_model_configs). All of the methods above could still fail the same way if the project was deleted after theProjectobject was fetched. I left them alone to keep this change small.Tests
New unit tests in
tests/unit/test_unit_project_move_data_rows_to_task_queue.py, with a mocked client (no API key needed). One of them sends a realRESOURCE_NOT_FOUNDresponse body through the request client, so it covers the whole path from the server answer to the raised error.TypeError: 'NoneType' object is not subscriptableon the missing-queue path.New integration test
test_move_to_task_invalid_queue_idintests/integration/test_task_queue.py. It needs a live API key, so I did not run it locally.Checks run locally:
ruff format --checkandruff checkonlibs/labelbox, andmypy src. All clean.Type of change
All Submissions
Changes to Core Features
🤖 Generated with Claude Code